#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <termios.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include "cssl.h"
#include <malloc.h>

typedef enum _field_
{
    _FIELD_SCA,
    _FIELD_PDU_TYPE,
    _FIELD_OA,
    _FIELD_PID,
    _FIELD_DCS,
    _FIELD_SCTS,
    _FIELD_UDL,
    _FIELD_UD,
}_FIELD_t; //扫描PDU字串时记录当前字符串位置的所在的字段位置


typedef struct _pdu_SCA
{
    int len; //服务中心号码长度
    int tosca; //服务中心类型
    char *address; //服务中心地址
}_SCA_t;  //服务中心号码

typedef struct _pdu_OA
{
    int len; //号码长度
    int tosca; //地址类型
    char *address; //号码地址
}_OA_t;  //原地址

typedef struct _pdu_SCTS
{
    uint8_t year;
    uint8_t month;
    uint8_t day;
    uint8_t hour;
    uint8_t minute;
    uint8_t second;
    uint8_t time_zone;
}_SCTS_t; //服务中心时间


typedef struct _pdu
{
    _SCA_t SCA; //服务中心号码
    uint8_t PDU_type; //PDU类型
    _OA_t OA;//原地址
    uint8_t PID;//协议标识
    uint8_t DCS;//数据编码方法
    _SCTS_t SCTS; //服务中心时间
    uint8_t UDL;//用户数据长度
    char *UD;//用户数据
}_SMS_PDU_t;


char *pdu = "0891683108200455F6240EA121256005869599000851109031910523525F8B946B003A67E58BE20020002367E58BE20031002367E58BE2624B673A000A67E58BE20020002367E58BE20031002367E58BE2624B673A000A67E58BE20020002367E58BE20031002367E58BE2624B673A";


_SMS_PDU_t *SMS_PDU_encode(char *pdu)
{
    int i = 0;
    int pdu_rcv_len = 0; //收到的PDU字符串
    _FIELD_t now_field = _FIELD_SCA; //当前字段
    _SMS_PDU_t *sms = NULL;
    sms = (_SMS_PDU_t *) malloc (sizeof(_SMS_PDU_t));

    if (sms != NULL)
        return NULL;

    pdu_rcv_len = strlen (pdu);
    //扫描字节流
    for (i = 0; i < pdu_rcv_len; i ++)
    {
        switch (now_field)
        {
            case _FIELD_SCA :
                
                break;
            case _FIELD_PDU_TYPE :
                break;
            default :
                break;
        }
    }
    return sms;
}


int main(int argc, char *argv[])
{
    printf ("[se]%d\n",sizeof(_SMS_PDU_t));
    exit (EXIT_SUCCESS);
}

